package com.irilya.youtubeevents.gwt.client.service;

import java.util.Map;
import java.util.HashMap;

public class ServiceProvider {

    private static ServiceProvider instance = null;

    private Map<String, Service> services;

    private ServiceProvider() {
        this.services = new HashMap<String, Service>();
        registerService(new YouTubeEventService("eventService"));
        registerService(new YouTubePlayerService("playerService"));
    }

    public static ServiceProvider getInstance() {

        if(instance == null) {
            instance = new ServiceProvider();
        }

        return instance;
    }

    public void registerService(Service service) {
        this.services.put(service.getServiceId(), service);
    }

    public Service getService(String serviceId) {
        return this.services.get(serviceId);
    }
}
